#pragma once
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>

using namespace std;

class Article
{
private:
	int id;
	string date;
	string title;
	string writer;
	int n;
	string keyword;
public:

	Article()
	{
		date = title = writer = keyword = "N/A";
		id = n = -1;
	}

	Article(int id,  string date, string title, string writer, int n, string keyword)
	{
		this->id = id;
		this->date = date;
		this->title = title;
		this->writer = writer;
		this->n = n;
		this->keyword = keyword;
	}

	~Article(){ }

	void setId(int id){ this->id = id; }
	void setDate(string date){ this->date = date; }
	void setTitle(string title){ this->title = title; }
	void setWriter(string writer){ this->writer = writer; }
	void setN(int n){ this->n = n; }
	void setKeyword(string keyword){ this->keyword = keyword; }

	int getId(){ return id; }
	string getDate(){ return date; }
	string getTitle(){ return title; }
	string getWriter(){ return writer; }
	int getN(){ return n; }
	string getKeyword(){ return keyword; }

	void Write()
	{
		cout << "Id: " << id << ", Date: " << date << ", Title: " << title << ", Writer: " << writer << ", n: " << n << ", Keyword: " << keyword << endl;
	}

	void Read()
	{
		string str;
		cout << "Id: ";
		getline(cin, str);
		{
			istringstream iss(str);
			iss >> id;
		}
		cout << "Date: ";
		getline(cin, date);
		cout << "Title: ";
		getline(cin, title);
		cout << "Writer: ";
		getline(cin, writer);
		cout << "N: ";
		getline(cin, str);
		{
			istringstream iss(str);
			iss >> n;
		}
		cout << "Keyword: ";
		getline(cin, keyword);
	}

	friend ostream& operator<<(ostream& out, const Article &a)
	{
		out << "(";
		out << a.id << ",";
		out << a.date << ",";
		out << a.title << ",";
		out << a.writer << ",";
		out << a.n << ",";
		out << a.keyword << ")";
		return out;
	}

	friend istream& operator>>(istream &in, Article &a)
	{
		string str;
		getline(in, str, '(');
		getline(in, str, ',');
		{
			istringstream iss(str);
			iss >> a.id;
		}
		getline(in, a.date, ',');
		getline(in, a.title, ',');
		getline(in, a.writer, ',');
		getline(in, str, ',');
		{
			istringstream iss(str);
			iss >> a.n;
		}
		getline(in, a.keyword, ')');
		return in;
	}

	virtual void print()
	{
		cout << "Id: " << id << ", Date: " << date << ", Title: " << title << ", Writer: " << writer << ", n: " << n << ", Keyword: " << keyword;
	}
};

